/* 基础样式重置 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: white;
    min-height: 100vh;
    color: #333;
    margin: 0;
    padding: 0;
}

.app-container {
    width: 100%;
    min-height: 100vh;
    background: white;
}

/* 头部样式 */
.header {
    background: #f8f9fa;
    color: #333;
    padding: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #2c3e50;
}

.file-operations {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* 按钮样式 */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-success {
    background: #27ae60;
    color: white;
}

.btn-success:hover {
    background: #229954;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* 主要内容区域 */
.main-content {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* 区块样式 */
.section {
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    overflow: hidden;
}

.section:hover {
    border-color: #ced4da;
}

.section-header {
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    font-size: 1.3rem;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-controls {
    display: flex;
    gap: 0.5rem;
}

/* 表格样式 */
.table-container {
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
    white-space: nowrap;
    min-width: 140px;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
    transition: background 0.3s ease;
}

.data-table input,
.data-table select {
    width: 100%;
    padding: 0.3rem;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.8rem;
}

.data-table input:focus,
.data-table select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* 信号预览样式 */
.signal-preview {
    padding: 1.5rem;
}

.preview-section {
    margin-bottom: 2rem;
}

.preview-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #2c3e50;
    border-left: 4px solid #3498db;
    padding-left: 0.5rem;
}

.byte-layout {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
}

.bit-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.bit-indices {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 1px;
    background: #dee2e6;
    border-radius: 4px;
    overflow: hidden;
    min-width: 200px;
}

.bit-indices span {
    background: white;
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.frame-data,
.signal-mask {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    min-height: 100px;
    border: 2px dashed #ced4da;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-style: italic;
}

.calculation-area {
    background: #e3f2fd;
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.calc-input,
.calc-result {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.calc-input label,
.calc-result label {
    font-weight: 600;
    color: #1976d2;
}

.calc-input input {
    padding: 0.5rem;
    border: 2px solid #90caf9;
    border-radius: 6px;
    font-size: 1rem;
    min-width: 200px;
}

.calc-input input:focus {
    outline: none;
    border-color: #1976d2;
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.calc-result span {
    font-weight: 600;
    color: #1976d2;
    background: white;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    border: 1px solid #90caf9;
}

/* DBC预览样式 */
.dbc-preview {
    max-height: 300px;
    overflow: auto;
    background: #263238;
    color: #eceff1;
    padding: 1.5rem;
    font-family: 'Courier New', monospace;
    line-height: 1.4;
}

.dbc-preview pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .file-operations {
        justify-content: center;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .section-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .calc-input,
    .calc-result {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .calc-input input {
        min-width: 100%;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section {
    animation: fadeIn 0.6s ease-out;
}

/* 全屏模式样式 */
.fullscreen .app-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    border-radius: 0;
    z-index: 9999;
}

/* 表格行选中状态 */
.data-table tbody tr.selected {
    background: #e3f2fd !important;
    border-left: 4px solid #1976d2;
}

/* 可点击行样式 */
.data-table tbody tr[style*="cursor: pointer"] {
    cursor: pointer;
}

.data-table tbody tr[style*="cursor: pointer"]:hover {
    background: #f0f8ff;
}

/* 错误和成功状态 */
.error {
    border-color: #e74c3c !important;
    background: #fdf2f2 !important;
}

.success {
    border-color: #27ae60 !important;
    background: #f2f9f2 !important;
}

/* 针对CAN信号表格的特殊样式 */
#canSignalsTable th,
#canSignalsTable td {
    min-width: 80px;
    padding: 0.75rem 0.5rem;
}

/* 为选择列设置较小宽度 */
#canSignalsTable th:nth-child(1),
#canSignalsTable td:nth-child(1),
#canMessagesTable th:nth-child(1),
#canMessagesTable td:nth-child(1) {
    min-width: 50px;
    text-align: center;
}

/* 为名称列设置更大宽度 */
#canSignalsTable th:nth-child(2),
#canSignalsTable td:nth-child(2),
#canMessagesTable th:nth-child(2),
#canMessagesTable td:nth-child(2) {
    min-width: 150px;
}

/* 为类型列设置合适宽度 */
#canSignalsTable th:nth-child(3),
#canSignalsTable td:nth-child(3) {
    min-width: 90px;
}

/* 为字节序列设置合适宽度 */
#canSignalsTable th:nth-child(4),
#canSignalsTable td:nth-child(4) {
    min-width: 80px;
}

/* 为模式列设置合适宽度 */
#canSignalsTable th:nth-child(5),
#canSignalsTable td:nth-child(5) {
    min-width: 80px;
}

/* 为数字列设置一致的较小宽度 (起始位、长度、因子、偏移、最小值、最大值) */
#canSignalsTable th:nth-child(6),  /* 起始位 */
#canSignalsTable td:nth-child(6),
#canSignalsTable th:nth-child(7),  /* 长度 */
#canSignalsTable td:nth-child(7),
#canSignalsTable th:nth-child(8),  /* 因子 */
#canSignalsTable td:nth-child(8),
#canSignalsTable th:nth-child(9),  /* 偏移 */
#canSignalsTable td:nth-child(9),
#canSignalsTable th:nth-child(10), /* 最小值 */
#canSignalsTable td:nth-child(10),
#canSignalsTable th:nth-child(11), /* 最大值 */
#canSignalsTable td:nth-child(11) {
    min-width: 70px;
    max-width: 70px;
    width: 70px;
    text-align: center;
}

/* 确保数字列输入框样式一致 */
#canSignalsTable td:nth-child(6) input,  /* 起始位 */
#canSignalsTable td:nth-child(7) input,  /* 长度 */
#canSignalsTable td:nth-child(8) input,  /* 因子 */
#canSignalsTable td:nth-child(9) input,  /* 偏移 */
#canSignalsTable td:nth-child(10) input, /* 最小值 */
#canSignalsTable td:nth-child(11) input  /* 最大值 */ {
    width: 100% !important;
    text-align: center;
    font-size: 0.8rem;
    padding: 0.3rem 0.2rem;
}

/* 为单位列设置合适宽度 */
#canSignalsTable th:nth-child(12),
#canSignalsTable td:nth-child(12) {
    min-width: 60px;
}

/* 为注释列设置更大宽度 (现在是第13列) */
#canSignalsTable th:nth-child(13),
#canSignalsTable td:nth-child(13),
#canMessagesTable th:nth-child(7),
#canMessagesTable td:nth-child(7) {
    min-width: 250px;
}

/* 为操作列设置较小宽度 */
#canSignalsTable th:nth-child(14),
#canSignalsTable td:nth-child(14),
#canMessagesTable th:nth-child(8),
#canMessagesTable td:nth-child(8) {
    min-width: 80px;
    text-align: center;
} 